package com.poizon.infrastructure.center.config.starter.apollo;

import cn.hutool.core.bean.BeanUtil;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.poizon.infrastructure.center.config.core.value.dto.ConfigChangeEventDto;
import com.poizon.infrastructure.center.config.core.event.listener.AbstractChangeListener;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@AllArgsConstructor
public class ApolloChangeListener implements ConfigChangeListener {
    private AbstractChangeListener abstractChangeListener;

    @Override
    public void onChange(ConfigChangeEvent configChangeEvent) {
        log.info(">监听到apollo配置变更");
        abstractChangeListener.onChange(BeanUtil.copyProperties(configChangeEvent, ConfigChangeEventDto.class));
    }
}
